/*
Author: Surpass-HC
Source: https://gitee.com/hxchuan000/clpc-1
Mail: surpass-hc@qq.com
*/
#ifndef __TASK_MANAGER_H__
#define __TASK_MANAGER_H__
#include <systime.h>
typedef void (*taskFuncDef)(void);
struct taskDef
{
    taskFuncDef initFunc;//初始化
    taskFuncDef runFunc;//跑
    taskFuncDef quitFunc;//退出
    sysTmTp intervalTime; // ms, task interval time.
    sysTmTp lastTaskTime; // ms, save last task run time
};
//任务管理
struct taskManageDef
{
    struct taskDef *t;
    uint16_t taskLen;
    uint16_t taskIndex;
};

#define TASK_DEFINE(initf, runf, quitf, intervalT) {initf, runf, quitf, intervalT, 0}
#define TASK_MAX_RUN_TIME_MS 5

void schedulerInit(struct taskManageDef *taskMmg);
void schedulerQuit(struct taskManageDef *taskMmg);
void schedulerRun(struct taskManageDef *taskMmg);
#endif
